package com.china08.yxyapi.repository.mg.lecture.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import com.china08.yxyapi.entity.mg.lecture.YxyLecturePrePack;

/**
 * @author Richard.Wang
 * @descript 备授课资源包
 */
public class YxyLecturePrePackRepositoryImpl {

    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * pv数量加1
     * 
     * @param prepackId
     */
    public void lecturePvPlus(String prepackId) {
        mongoTemplate.updateFirst(new Query(Criteria.where("id").is(prepackId)), new Update().inc("pv", 1),
                YxyLecturePrePack.class);
    }

    /**
     * 采纳量,使用量
     * 
     * @param prepackId
     */
    public void lectureUsedPlus(String prepackId) {
        mongoTemplate.updateFirst(new Query(Criteria.where("id").is(prepackId)), new Update().inc("used_count", 1),
                YxyLecturePrePack.class);
    }
}
